/*
 * @Author: windys
 * @Description: 
 * @Date: 2021-10-12 13:39:07
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import themePreprocessorPlugin from "@zougt/vite-plugin-theme-preprocessor"; //主题

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
  themePreprocessorPlugin({
    less: {
      // 各个主题文件的位置
      multipleScopeVars: [
        // {
        //   scopeName: "theme-default",
        //   path: path.resolve("src/theme/default.less"),
        // },
        // {
        //   scopeName: "theme-green",
        //   path: path.resolve("src/theme/green.less"),
        // },
        // {
        //   scopeName: "theme-orange",
        //   path: path.resolve("src/theme/orange.less"),
        // },
        // {
        //   scopeName: "theme-red",
        //   path: path.resolve("src/theme/red.less"),
        // },
      ],
    }
  }),
  ],
  base: './',
  resolve: {
    alias: {
      // 如果报错__dirname找不到，需要安装node,执行yarn add @types/node --save-dev
      "@": path.resolve(__dirname, "src"),
    }
  },
  server: {
    open: true,
    https: false,
    // port: 3000, // 端口号
    // host: "0.0.0.0",
    // proxy: {
    //   "/api": {
    //     target: "", // 后台接口
    //     changeOrigin: true,
    //     secure: false, // 如果是https接口，需要配置这个参数
    //     // ws: true, //websocket支持
    //     rewrite: (path) => path.replace(/^\/api/, ""),
    //   },
    // },
  },
  css: {
    // 开启less支持
    preprocessorOptions: {
      less: {
        // 主题
        // modifyVars: {
        //   'primary-color': '#1DA57A',
        //   'link-color': '#1DA57A',
        //   'border-radius-base': '2px',
        // },
        javascriptEnabled: true
      }
    },
    postcss: {
      plugins: [
        {
          postcssPlugin: 'internal:charset-removal',
          AtRule: {
            charset: (atRule) => {
              if (atRule.name === 'charset') {
                atRule.remove();
              }
            }
          }
        }
      ],
    },
  },
  // 引入第三方的配置
  optimizeDeps: {
    include: [],
  },
  esbuild: {
    jsxFactory: 'h',
    jsxFragment: 'Fragment'
  }
})
